Skip to content

gh-153539: Fix use-after-free in TextIOWrapper.tell() with a reentrant decoder#153540

Open
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:textio-tell-reentrant-uaf
Open

gh-153539: Fix use-after-free in TextIOWrapper.tell() with a reentrant decoder#153540
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:textio-tell-reentrant-uaf

Conversation

@tonghuaroot

Copy link
Copy Markdown
Contributor

TextIOWrapper.tell() used a borrowed next_input from the snapshot across the decoder's getstate/decode/setstate calls, so a decoder that re-enters seek() from getstate could free it and leave tell() reading freed memory. Own the reference across those calls, matching textiowrapper_read_chunk.

…entrant decoder

TextIOWrapper.tell() used a borrowed next_input from the snapshot across the
decoder's getstate/decode/setstate calls, so a decoder that reenters seek()
from getstate could free it and leave tell() reading freed memory. Own the
reference across those calls, matching the sibling textiowrapper_read_chunk.
@cmaloney cmaloney added 3.15 pre-release feature fixes, bugs and security fixes 3.16 new features, bugs and security fixes and removed 3.15 pre-release feature fixes, bugs and security fixes 3.16 new features, bugs and security fixes labels Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants